export const getTime = (time) => {
    var date = time;
    var year = date.getFullYear(); //返回指定日期的年份
    var month = repair(date.getMonth() + 1);//月
    var day = repair(date.getDate());//日
    var hour = repair(date.getHours());//时
    var minute = repair(date.getMinutes());//分
    var second = repair(date.getSeconds());//秒

    //当前时间
    var curTime = year + '-' + month + '-' + day
        + ' ' + hour + ':' + minute + ':' + second;
    return curTime;
};

export const getCurrentTime = ()=>{
    return getTime(new Date());
};

//补0

function repair(i) {
    if (i >= 0 && i <= 9) {
        return '0' + i;
    } else {
        return i;
    }
}